package com.joysuch.wwyt.alert;

import com.joysuch.wwyt.alert.service.AlertMessageService;
import com.joysuch.wwyt.alert.service.NoticeWaitingTriggerListService;
import com.joysuch.wwyt.api.dataaccess.OrientationDataSyncService;
import com.joysuch.wwyt.bp.repository.BpEnterpriseInfoDao;
import com.joysuch.wwyt.config.RedisClient;
import com.joysuch.wwyt.core.repository.BaseUserDao;
import com.joysuch.wwyt.core.service.BaseConfigService;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.sql.DataSource;

@Component
public class AlertListenerConfig implements InitializingBean, DisposableBean {

    private static AlertListenerConfig alertConfig = null;

    public static AlertListenerConfig getAlertConfig() {
        return alertConfig;
    }

    private AlertScheduler alertScheduler;

    @Override
    public void afterPropertiesSet() {
        alertConfig = this;
        alertScheduler = new AlertScheduler();
        alertScheduler.init();
    }

    @Override
    public void destroy() {
        alertScheduler.destroy();
    }

    @Resource
    private AlertMessageService alertMessageService;
    @Resource
    private NoticeWaitingTriggerListService noticeWaitingTriggerListService;
    @Resource
    private BaseUserDao baseUserDao;
    @Resource
    private RedisClient redisClient;
    @Resource
    private DataSource dataSource;
    @Resource
    private BpEnterpriseInfoDao bpEnterpriseInfoDao;
    @Resource
    private BaseConfigService baseConfigService;
    @Resource
    private OrientationDataSyncService orientationDataSyncService;

    public AlertMessageService getAlertMessageService() {
        return alertMessageService;
    }

    public NoticeWaitingTriggerListService getNoticeWaitingTriggerListService() {
        return noticeWaitingTriggerListService;
    }

    public BpEnterpriseInfoDao getBpEnterpriseInfoDao() {
        return bpEnterpriseInfoDao;
    }

    public void setBpEnterpriseInfoDao(BpEnterpriseInfoDao bpEnterpriseInfoDao) {
        this.bpEnterpriseInfoDao = bpEnterpriseInfoDao;
    }

    public BaseConfigService getBaseConfigService() {
        return baseConfigService;
    }

    public void setBaseConfigService(BaseConfigService baseConfigService) {
        this.baseConfigService = baseConfigService;
    }

    public OrientationDataSyncService getOrientationDataSyncService() {
        return orientationDataSyncService;
    }

    public void setOrientationDataSyncService(OrientationDataSyncService orientationDataSyncService) {
        this.orientationDataSyncService = orientationDataSyncService;
    }

    public BaseUserDao getBaseUserDao() {
        return baseUserDao;
    }

    public RedisClient getRedisClient() {
        return redisClient;
    }

    public DataSource getDataSource() {
        return dataSource;
    }
}
